<template>
<!-- 人气推荐 -->
  <div class="home-new" ref="target">
    <HomePanel title="人气推荐" sub-title="人气推荐" >
      <!-- 面板内容 -->
      <transition name="fade" >
        <!-- 情况1：显示列表 -->
      <ul class="goods-list" v-if="list.length">
        <li v-for="item in list" :key="item.id">
          <RouterLink to="/">
            <img :src="item.picture" alt="">
            <p class="name ellipsis">{{item.title}}</p>
            <p class="price">{{item.alt}}</p>
          </RouterLink>
        </li>
      </ul>
      <!-- 情况2：显示骨架效果 -->
      <HomeSkeleton v-else />
      </transition>
    </HomePanel>
  </div>
</template>
<script>
import HomePanel from './home-panel.vue'
import { findHot } from '@/api/home'
// 数据懒加载
import { useLazyData } from '@/hooks/index'
export default {
  components: { HomePanel },
  name: 'HomeHew',
  setup () {
    // 数据懒加载
    const { list, target } = useLazyData(findHot)
    return { list, target }
  }

}
</script>
<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    // background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: #999;
    }
  }
}
</style>
